import { createRouter, createWebHistory } from 'vue-router'
import SdyH from '@/views/SdyHome/index.vue'
import SdyCart from '@/views/SdyCart/index.vue'
import SdyCate from '@/views/SdyCategory/index.vue'
import SdyS from '@/views/SdySelf/index.vue'
import NotFound from '@/views/SdyFound/index.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
     {
      path:'/',
      redirect:'/home'
     },
     {
      path:'/home',
      name:'home',
      component:SdyH
     },
     {
      path:'/cart',
      name:'cart',
      component:SdyCart,
      meta:{hiddeninfo:true}
     },
     {
      path:'/cate',
      name:'cate',
      component:SdyCate
     },
     {
      path:'/self',
      name:'self',
      component:SdyS
     },
     {
      path:'/login',
      name:'login',
      component:()=>import('@/views/SdyLogin/index.vue'),
      meta:{hiddeninfo:true}
     },
     {
      path:'/detail',
      name:'detail',
      component:()=>import('@/views/SdyDetail/index.vue'),
      meta:{hiddeninfo:true}
    },
     {
      path:'/register',
      name:'register',
      component:()=>import('@/views/SdyRegister/index.vue'),
      meta:{hiddeninfo:true}
     },
     {
      path:'/goodslist',
      name:'goodslist',
      component:()=>import('@/views/SdyGoodsList/index.vue')
     },
     {
      path:'/search',
      name:'search',
      component:()=>import('@/views/SdySearch/index.vue'),
      meta:{hiddeninfo:true}
     },
     {
      // 乱七八糟跳到这
      path:'/:pathMatch(.*)*',
      redirect:'NotFound'
     },
     {
      path:'/NotFound',
      name:'NotFound',
      component:NotFound,
      // meta来控制某个组件显示与隐藏
      meta:{hiddeninfo:true}
     },
  ]
})

export default router
